#include "junix.h"
#include "list.h"

struct A
{
	int i;
	struct	list_head list;
};

int main(int argc, char **argv)
{
	int i=0;
	struct A *pa=NULL;

	struct A aa={0,LIST_HEAD_INIT(aa.list)};

	for(i=0;i<1000;i++)
	{
		pa = alloca(sizeof(struct A));
		memset(pa,0,sizeof(struct A));
		pa->i=i*2;
		INIT_LIST_HEAD(&pa->list);
		list_add(&pa->list,&aa.list);
	}

	struct list_head *pl;
	list_for_each(pl,&aa.list)
	{
		pa=list_entry(pl,struct A, list);
		printf("%i ",pa->i);
	}

	printf("\n");

    exit(0);
}

